<template>
  <div>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['system:dict:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="success"
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['system:dict:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="danger"
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['system:dict:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="warning"
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['system:dict:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <!--1视图-->
    <el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="字典编号" align="center" prop="id" />
      <el-table-column label="字典标签" align="center" prop="title" :show-overflow-tooltip="true" />
      <el-table-column label="字典排序" align="center" prop="sort" />
      <el-table-column label="字典键值" align="center" prop="val" />
      <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
      <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
      <el-table-column label="创建时间" align="center" prop="createdDate" width="180">
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.createdDate) }}</span>-->
<!--        </template>-->
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['system:dict:edit']"
          >修改</el-button>
          <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row.id)"
              v-hasPermi="['system:dict:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-dialog :visible.sync="open" width="700px" append-to-body>
      <el-form ref="form" :model="form" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="字典标签:">
              <el-input v-model="form.title" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="字典排序" >
              <el-input v-model="form.sort" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="字典键值" >
              <el-input v-model="form.val" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="状态" >
              <el-input v-model="form.status"  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input v-model="form.remark" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="创建时间" >
              <el-input type="date" v-model="form.createdDate" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="字典类型" >
              <el-input v-model="this.dictId"  disabled/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="add">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>

</template>

<script>


export default {
  name: "ContentView",
  data() {
    return {
      //2属性定义
      dataList:[],
      // 遮罩层
      loading: false,
      form:{},
      open:false,
      dictId:this.$route.params.dictId,
    }
  }, methods: {
    handleAdd(){
      this.open=true;
      this.form.dictId=this.dictId;
    },
    add(){
      this.axios.post("/redisservice/mydictionary/saveDictionary?",this.form).then(
          res=>{
            this.$message.success(res.data.msg);
            this.open=false;
            this.getList()
          }
      )
    },
    handleDelete(id){
      this.axios.post("/redisservice/mydictionary/deteleDictionary?dictId="+this.dictId+"&id="+id).then(
          res=>{
            this.$message.success(res.data.msg);
            this.getList()
          }
      )
    },
    // gopage(current){
    //   this.current=current;
    //   this.getList();
    // },
    getList(){
      var s = this.$route.params && this.$route.params.dictId;
      this.axios.post("/redisservice/mydictionary/getByDid?did="+s).then(
          res=>{
            this.dataList=res.data.data;
            // this.total=res.data.data.total;
          }
      )
    }
    //3自定义方法
  }, created() {
    this.getList()
    //4.钩子函数
  }
}
</script>

<style scoped>

</style>